#include "communication.h"

module* init_module(char *nom, int type, int bourse){
	module *rtn=(module*) malloc (sizeof (module));
	rtn->type=type;
	rtn->bourse_id=bourse;
	rtn->srv = malloc (sizeof (server));
	sprintf(rtn->name,"%s",nom);
	if(strlen(nom)>128) log_smth("ATTENTION: le nom du module \"%s\" est trop long",nom);
	return rtn;
}

void log_srv(const server* srv, char* un_msg) {
	char logged[1024];
	sprintf(logged, "Serveur %s(%d) %s", srv->name, srv->my_port, un_msg);
	private_write_log(comm_type, logged);
}

void log_msg_srv(const server* srv, msg* damsg, char* un_msg){
	char logged[1024];
	sprintf(logged, "%s: %s", srv->name, un_msg);
	log_msg(logged,damsg);
}
